unit DataMod;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DB, IfxCustomDataset, IfxQuery, IfxConnection, IfxUpdateSQL,
  LXDataSetImpl, LXUpdateSQL, IfxFileMonitor, IfxMonitor, IfxVisualMonitor;

type
  TCacheData = class(TDataModule)
    DataSource: TDataSource;
    IfxConnection: TIfxConnection;
    IfxQuery: TIfxQuery;
    IfxUpdateSQL: TIfxUpdateSQL;
    IfxQuerycustomer_num: TAutoIncField;
    IfxQueryfname: TStringField;
    IfxQuerylname: TStringField;
    IfxQueryUpdateStatus: TStringField;
    IfxCompositMonitor: TIfxCompositMonitor;
    IfxFileMonitor: TIfxFileMonitor;
    IfxVisualMonitor: TIfxVisualMonitor;
    procedure UpdateErrorHandler(DataSet: TDataSet; E: EDatabaseError;
      UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction);
    procedure IfxQueryCalcFields(DataSet: TDataSet);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  CacheData: TCacheData;

implementation

uses CachedUp, ErrForm;

{$R *.DFM}

{ This event is triggered when an error occurs during the update process
  (such as a key violation).  Here we use another form to show the user
  the error and allow them to decide what to do about it.  See ErrForm.pas
  for more information }

procedure TCacheData.UpdateErrorHandler(DataSet: TDataSet; E: EDatabaseError; UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction);
begin
  UpdateAction := UpdateErrorForm.HandleError(DataSet, E, UpdateKind);
end;

{ This event displays the current update status in a calculated field }

procedure TCacheData.IfxQueryCalcFields(DataSet: TDataSet);
const
  UpdateStatusStr: array[TUpdateStatus] of string = ('Unmodified', 'Modified', 'Inserted', 'Deleted');
begin
  if IfxQuery.CachedUpdates then
    IfxQueryUpdateStatus.Value := UpdateStatusStr[IfxQuery.UpdateStatus] else
    IfxQueryUpdateStatus.Value := '';
end;


end.

